package edu.ucsd.cse135.gas.action.chair;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.ucsd.cse135.gas.bean.chair.GreForm;
import edu.ucsd.cse135.gas.logic.GRE;
import edu.ucsd.cse135.gas.resources.Constants;

public class GreToDatabaseAction extends Action{

	public GreToDatabaseAction() {
		super();
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
	
		GreForm greForm = (GreForm)form;
		
		GRE gre = new GRE();
		
		gre.setApplicant(greForm.getApplicant());
		gre.setAnalytical(greForm.getAnalytical());
		gre.setAnalyticalPercent(greForm.getAnalyticalPercent());
		gre.setVerbal(greForm.getVerbal());
		gre.setVerbalPercent(greForm.getVerbalPercent());
		gre.setQuantitative(greForm.getQuantitative());
		gre.setQuantitativePercent(greForm.getQuantitativePercent());
		gre.setTotal(greForm.getTotal());
		gre.setTotalPercent(greForm.getTotalPercent());
		gre.setType(greForm.getType());
		gre.setMonth(greForm.getMonth());
		gre.setYear(greForm.getYear());
		gre.setRegNo(greForm.getRegNo());
		
		gre.writeToDatabase();
		
		return mapping.findForward(Constants.SUCCESS);
	}
}
